package com.wd.tech.fragment;

import android.view.View;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;
import butterknife.BindView;

import com.wd.tech.R;
import com.wd.tech.adapter.Xiaoxi.TabAdapter;
import com.wd.tech.base.BaseFragment;
import com.wd.tech.base.BasePresenter;
import com.wd.tech.fragment.Xiaoxin.ContactFragment;
import com.wd.tech.fragment.Xiaoxin.NewsFragment;
import com.wd.tech.mvp.IPresenterImpl;

import java.util.ArrayList;
import java.util.List;

public class XiaoXiFragment extends BaseFragment {

    @BindView(R.id.xiaoxirg)
    RadioGroup rg;
    @BindView(R.id.xiaoxirb)
    RadioButton xiaorb;
    @BindView(R.id.lianxirb)
    RadioButton lianrb;
    @BindView(R.id.xiaoxivp)
    ViewPager vp;
   private NewsFragment newsFragment;
   private ContactFragment contactFragment;
 private List<Fragment> mFragmentList = new ArrayList<>();
 private TabAdapter tabAdapter;

 @Override
    protected void initData() {
      newsFragment = new NewsFragment();
      contactFragment = new ContactFragment();
      mFragmentList.add(newsFragment);
      mFragmentList.add(contactFragment);
      //适配器
      tabAdapter = new TabAdapter(getChildFragmentManager(), mFragmentList);
      //设置适配器
       vp.setAdapter(tabAdapter);
       rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
         switch (checkedId) {
          case R.id.xiaoxirb:
           vp.setCurrentItem(0);
           break;
          case R.id.lianxirb:
           vp.setCurrentItem(1);
           break;
         }

           }
       });

 }

    @Override
    protected BasePresenter initPresenter() {
        return new IPresenterImpl();
    }

    @Override
    protected void initView(View view) {

    }

    @Override
    protected int layoutId() {
        return R.layout.xiaoxi_fragment;
    }

    @Override
    public void success(Object o) {

    }

    @Override
    public void Error(Throwable throwable) {

    }

}
